package com.zsc.rediscli;

import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class RedisPoolTest {

    public static void main(String[] args) {
        GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
        JedisPool jedisPool = new JedisPool(poolConfig,"192.168.56.107",6379);

        Jedis jedis = null;
        try{
            jedis = jedisPool.getResource();
            jedis.set("hello","你好");
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if (jedis != null)
            //使用jedisPool,close()操作不是关闭连接，代表归还连接池
            jedis.close();
        }



    }
}
